//
//  UIView+Draw.m
//  KKCategoryKit
//
//  Created by liaozhenming on 16/10/12.
//  Copyright © 2016年 liaozhenming. All rights reserved.
//

#import "UIView+Draw.h"

@implementation UIView (Draw)

- (void)kk_addRadius:(float)radius {
    
    self.layer.cornerRadius = radius;
    self.layer.masksToBounds  = YES;//使用边界来做遮罩
}

- (void)kk_addBorderWithColor:(UIColor*)color width:(CGFloat)width {
    
    self.layer.borderWidth = width;
    self.layer.borderColor = [color CGColor];
}


- (UIImage*)kk_drawView {
    
    UIGraphicsBeginImageContextWithOptions(self.bounds.size, YES, 0.0);
    [self drawViewHierarchyInRect: self.bounds afterScreenUpdates: NO];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}

@end
